//
//  ECMineAboutMeViewController.m
//  Edu_iOS2018
//
//  Created by apple on 2018/1/29.
//  Copyright © 2018年 yanyan. All rights reserved.
//

#define UILABEL_LINE_SPACE 5

#import "ECMineAboutMeViewController.h"

@interface ECMineAboutMeViewController ()

@property (weak, nonatomic) IBOutlet UILabel *versionLab;
@property (weak, nonatomic) IBOutlet UILabel *contentLab;

@end

@implementation ECMineAboutMeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"关于我们";
    
    NSString *contentText = @"学缘网是山东康华传媒集团旗下互联网教育平台，为学习者提供海量免费、优质的视频课程。你可以通过平台传授你的课程，分享你的资源，亦可在线学习你所需要的知识、获取各类教育资源。";
    [self setLabelSpace:self.contentLab withValue:contentText withFont:[UIFont systemFontOfSize:16.f]];
    self.contentLab.numberOfLines = 0;
    
    //版本号
    NSString *versionString = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
    self.versionLab.text = [NSString stringWithFormat:@"Version %@",versionString];
    self.versionLab.layer.cornerRadius = 8.f;
    self.versionLab.layer.masksToBounds = YES;
}

//给UILabel设置行间距和字间距
-(void)setLabelSpace:(UILabel*)label withValue:(NSString*)str withFont:(UIFont*)font {
    NSMutableParagraphStyle *paraStyle = [[NSMutableParagraphStyle alloc] init];
    paraStyle.lineBreakMode = NSLineBreakByCharWrapping;
    paraStyle.alignment = NSTextAlignmentLeft;
    paraStyle.lineSpacing = UILABEL_LINE_SPACE; //设置行间距
    paraStyle.hyphenationFactor = 1.0;
    paraStyle.firstLineHeadIndent = 0.0;
    paraStyle.paragraphSpacingBefore = 0.0;
    paraStyle.headIndent = 0;
    paraStyle.tailIndent = 0;
    
    //设置字间距 NSKernAttributeName:@1.1f
    NSDictionary *dic = @{NSFontAttributeName:font, NSParagraphStyleAttributeName:paraStyle, NSKernAttributeName:@1.f
                          };
    NSAttributedString *attributeStr = [[NSAttributedString alloc] initWithString:str attributes:dic];
    label.attributedText = attributeStr;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
